home *** CD-ROM | disk | FTP | other *** search
- /* PGPread.rexx 1.1 by knikulai@utu.fi - 07-May-97
- ** Go check http://www.utu.fi/~knikulai/ARexx.html for other useful scripts!
- **
- ** - Environment variables PGPPASS and PGPPATH need to be set correctly.
- ** - Edit the variables in the beginning of the script to suit your system
- ** - If the script doesn't work, execute it from shell so you can see the
- ** output and maybe figure out what is wrong.
- */
-
- options results
- scrn='YAMscreen' /* Change the correct value here or leave it like this*/
- pgp='work:pgp/bin/PGP' /* Where is PGP? */
- opts='-sea' /* Options for encoding reply */
- outdir='ram:' /* decoded message is written here */
- pager='c:Next' /* This program is used to display the decoded message */
- editor='sys:tools/memacs'/* This editor is used to write the reply */
- quote='>' /* This is added in the beginning of each line if you reply */
-
- /* WARNING: If you change something below this line, things might stop working! */
-
- address 'YAM'
- 'GetMailInfo file' /* Get the filename of the message */
- if rc>0 then do
- 'Request "You need to select a message first!" "_Ok"'
- exit
- end
- fn=result
- 'GetMailInfo From' /* Who sent it? */
- to_id=result
- if pos('<',result)>0 then to_id=translate(substr(result,pos('<',result)),'','><','')
-
-
- /* Create a name for decoded message */
- x=lastpos('/',fn)
- y=lastpos(':',fn) /* Remove path */
- if x<y then x=y
- outname=outdir || substr(fn,x+1) || '.plain'
-
- address command 'delete >nil:' outname /* Make sure there isn't that file already */
-
- /* Open Shell window and redirect STDIN and STDOUT */
- Call Close(STDOUT)
- Call Close(STDIN)
- Call Open(STDOUT,'CON:1/11/638/130/PGP Output/CLOSE/WAIT/SCREEN'scrn,'w')
- Call Pragma('*',STDOUT)
- Call Open(STDIN,'*')
-
- address command pgp fn '-o' outname /* Decode the message */
- address command pager outname /* Display the message */
- address 'YAM' 'Request "Do you want to reply the message?" "_Yes|_No"'
- if result=0 then exit
-
- /* Quote the decoded message */
- if open(decoded,outname,'r') & open(quoted,outdir'quoted.msg','w') then do
- do while ~eof(decoded)
- r=readln(decoded)
- call writeln(quoted,quote || r)
- end
- call close(quoted)
- call close(decoded)
- end
- else do /* Either file couldn't be opened */
- 'Request "Can not quote the message!" "_Ok"'
- say "You can close the window now"
- exit
- end
- 'Request "Do you want to encode your reply?" "_Yes encode it|_No, use plain text"'
- if result=1 then do
- address command editor outdir'quoted.msg'
- address command 'delete >nil:' outdir'encoded.msg'
- address command pgp opts outdir'quoted.msg -o' outdir'encoded.msg' to_id
- address 'YAM'
- 'MailReply'
- 'WriteLetter' outdir'encoded.msg'
- end
- else do
- address 'YAM'
- 'MailReply'
- 'WriteLetter' outdir'quoted.msg'
- end
- say "You can close the window now"
- Call Close(STDOUT)
- Call Close(STDIN)
- exit
-